package com.kw.drug.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kw.drug.entity.Returngoods;
import com.kw.drug.entity.Returnsupplier;
import com.kw.drug.entity.Supplier;
import com.kw.drug.mapper.ReturnsupplierMapper;
import com.kw.drug.service.ReturnSupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ReturnSupplierServiceImpl implements ReturnSupplierService {
    @Autowired
    ReturnsupplierMapper returnsupplierMapper;

    @Override
    public IPage<Returnsupplier> problemQueryPage(String param, Integer pageSize, Integer pageNum) {
        QueryWrapper<Returnsupplier> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(param)) {
            queryWrapper.like("dname", param);
        }
        Page<Returnsupplier> page = new Page<>(pageNum, pageSize);
        Page<Returnsupplier> page1 = returnsupplierMapper.selectPage(page, queryWrapper);
        return page1;
    }

    @Override
    public Returnsupplier selectreturnSupplierById(Integer id) {
        Returnsupplier returnsupplier = returnsupplierMapper.selectById(id);
        return returnsupplier;
    }

    @Override
    public Integer updateSupplierById(Returnsupplier returnsupplier) {
        int i = returnsupplierMapper.updateById(returnsupplier);
        return i;
    }

    @Override
    public Integer deleteReturnsupplierById(Integer id) {
        int i = returnsupplierMapper.deleteById(id);
        return i;
    }

    @Override
    public Integer addReturnsupplier(Returnsupplier returnsupplier) {
        int insert = returnsupplierMapper.insert(returnsupplier);
        return insert;
    }

}
